package ic.doc.co2nudge.shared;

import java.util.HashMap;

public class Constants {

	private static Constants constants=null;
	private static HashMap<String, Integer> constantsMapper=null; 
	
	public static Constants getConstants(){
		if (constants==null)
			constants=new Constants();
		return constants;
	}
	
	private Constants(){
		
		constantsMapper=new HashMap<String, Integer>();
		constantsMapper.put( "Bicycle", BICYCLE_EMISSION_RATE);
		constantsMapper.put( "Rail", RAIL_EMISSION_RATE);
		constantsMapper.put( "Small_Car", SMALL_CAR_EMISSION_RATE);
		constantsMapper.put( "Family_Car", FAMILY_CAR_EMISSION_RATE);
		constantsMapper.put( "Bus", BUS_EMISSION_RATE);
		constantsMapper.put( "Taxi", TAXI_EMISSION_RATE);
		constantsMapper.put( "Aircraft", AIRCRAFT_EMISSION_RATE);
		constantsMapper.put( "MinimalDistanceForFlight", MINIMAL_DISTANCE_FOR_FLIGHT);

	}
	
	//general constants
	private static final Double GALLON=		4.54609188D;
	private static final Double MILE=		1.609344D;
	
	//fuel emision rates - per litr (in kg)
	private static final Double MOTOR_GASOLINE=8.91/GALLON;
	private static final Double AVIATION_GASOLINE=8.32/GALLON;
	private static final Double DIESEL_FUEL=10.15/GALLON;
	
	//CO2 emission rates - per km (in g)
	private static final Integer BICYCLE_EMISSION_RATE=0; 
	private static final Integer TAXI_EMISSION_RATE=233; //TX4
	private static final Integer SMALL_CAR_EMISSION_RATE=91; //Volkswagen Polo
	private static final Integer FAMILY_CAR_EMISSION_RATE=130; 
	private static final Integer BUS_EMISSION_RATE=180; //Bus
	private static final Integer AIRCRAFT_EMISSION_RATE=250;
	private static final Integer RAIL_EMISSION_RATE=60;
	
	private static final Integer MINIMAL_DISTANCE_FOR_FLIGHT=100000;
	
	public Integer getConstant(String key){
		return constantsMapper.get(key);
	}
	
	public Double getGallonConst(){
		return GALLON;
	}
	
	public Double getMileConst(){
		return MILE;
	}
}
